package com.majun.huaxishe.controller;


import com.majun.huaxishe.entity.Background;
import com.majun.huaxishe.result.Result;
import com.majun.huaxishe.service.IBackgroundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 主页背景图表 前端控制器
 * </p>
 *
 * @author 马骏
 * @since 2024-03-07
 */
@RestController
@RequestMapping("/background")
@CrossOrigin
public class BackgroundController {

    @Autowired
    private IBackgroundService backgroundService;

    @GetMapping("/findById")
    public Result<Background> findById (){
        Background background = backgroundService.getById(1);
        return Result.success(background);
    }

    @PostMapping("/changeBackground")
    public Result changeBackground(@RequestBody Background background){
        backgroundService.updateById(background);
        return Result.success();
    }
}
